ABC166 E - This Message Will Self-Destruct in 5s
提出
code: python
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
解答
code: python
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
ans = 0
# i, j (i < j) について
# j − i = Ai + Aj
# <=>
# i + Ai(=l) = j − Aj(=r)
l = []
r = []
for x, y in enumerate(a):
l.append(x + y)
r.append(x - y)
count = Counter(r)
for i in l:
print(ans)
メモ
提出
code: python
n = int(input())
a = list(map(int, input().split()))
ans = 0
# 計算量
# 値が相対的なので走査するしかない
# 累積和, DPの必要なし
for i in range(n):
for j in range(i+1):
ans += 1
print(ans)